<template>
	<view>
		<view class="no-content" v-if=" list==null||list.length===0">
			<text>已将到底了</text>
		</view>
		<view v-for="(item, index) in list" :key="index">
			<uni-collapse class="warp">
				<view v-if="item.apply == 0">
					<view class="show">
						<image src="../../../static/image/result/waiting.png"></image>
					</view>
					<uni-collapse-item :show-animation="true" :title="item.time.substr(0,4)+'年度申请'">
						<text class="content" v-if="item.teaRecruitApplyId!==null && item.teaRecruitApplyId!==''">
							<text class="iconfont" style="color: #e64340;">&#xe7cb;</text>变更编号：{{item.teaRecruitApplyId}}
						</text>
						<text class="content" v-if="item.teaRecruitId!==null && item.teaRecruitId!==''">
							<text class="iconfont" style="color: #e609b6;">&#xe611;</text>申请id：{{item.teaRecruitId}}
						</text>
						<text class="content" v-if="item.time!==null && item.time!==''">
							<text class="iconfont" style="color: #05dbe6;">&#xe62a;</text>申请时间：{{item.time}}
						</text>
					</uni-collapse-item>
				</view>
				<view v-else>
					<view class="show">
						<image v-if="item.past == 0" src="../../../static/image/result/unpass.png"></image>
						<image v-else src="../../../static/image/result/pass.png"></image>
					</view>
					<uni-collapse-item :show-animation="true" :title="item.time.substr(0,4)+'年度申请'">
						<text class="content" v-if="item.teaRecruitApplyId!==null && item.teaRecruitApplyId!==''">
							<text class="iconfont" style="color: #e64340;">&#xe7cb;</text>变更编号：{{item.teaRecruitApplyId}}
						</text>
						<text class="content" v-if="item.teaRecruitId!==null && item.teaRecruitId!==''">
							<text class="iconfont" style="color: #e609b6;">&#xe611;</text>申请id：{{item.teaRecruitId}}
						</text>
						<text class="content" v-if="item.time!==null && item.time!==''">
							<text class="iconfont" style="color: #05dbe6;">&#xe62a;</text>申请时间：{{item.time}}
						</text>
						<text class="content" v-if="item.past!==null && item.past!==''">
							<text class="iconfont" style="color: #e6c91f;">&#xe76d;</text>审核结果：
							<text class="iconfont r1" v-if="item.past==1">&#xe61b;</text>
							<text class="iconfont r2" v-else>&#xe625;</text>
						</text>
						<view class="content" v-if="item.past!==null && item.past!=='' &&item.past==1 &&item.time.substr(0,4)==now">
							<button type="primary" v-if="item.type==0" @click="go(0, item.teaRecruitApplyId)"><text class="iconfont">&#xe807;</text>填写信息</button>
							<button type="primary" v-if="item.type==1" @click="go(item.teaRecruitId,item.teaRecruitApplyId)"><text class="iconfont">&#xe807;</text>前往修改信息</button>
						</view>
					</uni-collapse-item>
				</view>
			</uni-collapse>
		</view>
	</view>
</template>

<script>
	import {
		applyList,
		delRecruitApply
	} from '@/api/tRecruit.js'

	import {
		uniCollapse,
		uniCollapseItem
	} from '@dcloudio/uni-ui'


	export default {
		components: {
			uniCollapse,
			uniCollapseItem
		},
		data() {
			return {
				list: [],
				now: ''
			}
		},
		methods: {
			getData() {
				uni.showLoading()
				applyList({
					tid: getApp().globalData.tid,
					apply: 1,
				}).then(res1 => {
					this.list = res1.data.data
					applyList({
						tid: getApp().globalData.tid,
						apply: 0,
					}).then(res2 => {
						this.list = this.list.concat(res2.data.data)
						this.list.sort(function(obj1, obj2) {
							const t1 = obj1.time.substr(0, 4)
							const t2 = obj2.time.substr(0, 4)
							return Number(t1) < Number(t2)
						})
						uni.hideLoading()
					})
				}).catch(err => {
					// console.log(err)
					uni.showModal({
						content: '请求失败'
					})
				})
			},
			go(teaRecruitId, teaRecruitApplyId) {
				uni.navigateTo({
					url: './apply?teaRecruitId=' + teaRecruitId + '&teaRecruitApplyId=' + teaRecruitApplyId
				})
			}
		},
		onLoad() {
			this.now = new Date().getFullYear()
			this.getData()
		}
	}
</script>

<style>
	page {
		font-family: 'Courier New', Courier, monospace;
	}

	.iconfont {
		font-family: "iconfont" !important;
		font-size: 20px;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.inv-h-w {
		height: 50px;
		background-color: #ffffff;
		border-bottom: 1px solid #F7F7F7;
	}

	.inv-card {
		height: 100%;
		line-height: 50px;
		display: inline-block;
		position: relative;
	}

	.inv-card .title {
		color: #FFFFFF;
		height: 50px;
		font-size: 18px;
		box-sizing: border-box;
		background-color: #ffaa00c2;
		padding-right: 40px;
		padding-left: 10px;
	}

	.inv-card .selected-title {
		background-color: #ffaa00;
	}

	.inv-card ::after {
		content: "";
		position: absolute;
		right: 0;
		top: 0;
		border-right: 50px solid white;
		border-left: 50px solid transparent;
		border-bottom: 50px solid transparent;
	}

	.no-content {
		display: flex;
		height: auto;
		padding: 10px;
		font-size: 14px;
		justify-content: center;
		align-items: center;
		background-color: #f7f7f7;
	}

	.content {
		padding: 15px;
		font-size: 18px;
		line-height: 20px;
		background-color: #fbfbfb;
		color: #666;
		border-bottom: 1px dotted #c8c7cc;
		margin: 0 5px 10px 5px;
		box-shadow: 5px 5px 3px #d3cfb0;
		border-radius: 5px;
	}

	.operaton {
		text-align: center;
	}

	.operaton button {
		margin: 0 20px;
	}

	.r1 {
		font-size: 50px;
		color: #4CD964;
	}

	.r2 {
		font-size: 50px;
		color: #e64340;
	}

	uni-collapse,
	uni-collapse-item {
		position: relative;
		z-index: auto;
	}

	.show {
		position: absolute;
		width: 40px;
		height: 40px;
		right: 50px;
		z-index: 10;
	}

	.show image {
		width: 50px;
		height: 50px;
	}
</style>
